//
//  TBNatioinView.m
//  Tourism
//
//  Created by zhi kuiyu on 16/1/23.
//  Copyright © 2016年 zhikuiyu. All rights reserved.
//

#import "TBNatioinView.h"

#define Width [UIScreen mainScreen].bounds.size.width

@implementation TBNatioinView
@synthesize leftBtn = _leftBtn;


- (id)initWithCoder:(NSCoder *)aDecoder{

    if(self = [super initWithCoder:aDecoder]){
        
    }
    return self;

}


- (void)setTitle:(NSString *)title{

    if(_titleView == nil){
        _titleView = [[UILabel alloc] initWithFrame:CGRectMake(100, 0, SCREEN_WIDTH - 100 * 2, self.frame.size.height)];
        
        _titleView.textAlignment = NSTextAlignmentCenter;
        [self addSubview:_titleView];
    }
    _titleView.text = title;
    
}
- (UIButton *)rightBtn{
    if(_rightBtn == nil){
        _rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_rightBtn addTarget:self action:@selector(rightAction:) forControlEvents:UIControlEventTouchUpInside];
        _rightBtn.frame = CGRectMake(20, 13, 20, 20);
        [_rightBtn setImage:[UIImage imageNamed:@"抽屉－按下"] forState:0];
        
        [self addSubview:_rightBtn];
    }
    return _rightBtn;
}

- (UIButton *)leftBtn{

    if(_leftBtn == nil){
        _leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_leftBtn addTarget:self action:@selector(leftAction:) forControlEvents:UIControlEventTouchUpInside];
        _leftBtn.frame = CGRectMake(SCREEN_WIDTH - 100, 0,100, self.frame.size.height);
        UILabel * label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 50)];
        label.text = @"查看计步";
        label.textColor = [UIColor blackColor];
        label.font = [UIFont systemFontOfSize:18];
        [_leftBtn addSubview:label];
        [self addSubview:_leftBtn];
    }
    return _leftBtn;
}
#pragma mark - ButtonAction
-(void)leftAction:(UIButton *)button{

    if(_delegate && [_delegate respondsToSelector:@selector(navtionLeftBtnAction:)]){
        [_delegate navtionLeftBtnAction:button];
    }
}
-(void)rightAction:(UIButton *)button{
    
    if(_delegate && [_delegate respondsToSelector:@selector(navtionrightBtnAction:)]){
        [_delegate navtionrightBtnAction:button];
        
    }
}




@end
